000100120821
002300120816     h nomain
002301120816     h option(*srcstmt)
002302120816     h debug(*no)
002303121001     h datfmt(*ISO)
002400120816
003001121028      /include qsrctxt,tracedata
003002121028      /include qsrctxt,csqlutil
003003120816
003005120816      //////////////////////////////////////////////////////////////////
003006120816      // Constant definition
003007120816      //////////////////////////////////////////////////////////////////
003008120816
003009120828     d CACHE_MAX_SIZE  c                   const(10000)
003010120816
003100120816      //////////////////////////////////////////////////////////////////
003101120816      // Global Variables
003102120816      //////////////////////////////////////////////////////////////////
003103120816
003200120816     d traceDataRecord...
003201120816     d               e ds                  extname(TRACEDATA) qualified
003300120816
003302120816     d cacheSize       s             10i 0 inz(0)
003303120816
003304120816     d recordCache     ds                  likeds(traceDataRecord)
003305120816     d                                     dim(CACHE_MAX_SIZE)
003306120816
003312120816      //////////////////////////////////////////////////////////////////
003313121001      // SQL Precompiler options
003314120816      //////////////////////////////////////////////////////////////////
003315120816
003316121001      /free
003317121001        EXEC SQL
003318121001         SET OPTION DATFMT = *ISO,
003321121001                    TIMFMT = *ISO;
003322121001      /end-free
003323121001
003324121001      //////////////////////////////////////////////////////////////////
003325121001      // Procedure definition
003326121001      //////////////////////////////////////////////////////////////////
003327121001
007000120816     p TRACEDATA_clear...
007100120816     p                 b                   export
007300120816     d                 pi
007400120816
007500120816      /free
007600120816       clear traceDataRecord;
007700120816       return ;
007800120816      /end-free
008100120816     p                 e
008200120816      //_______________________________________________________________________
011900120816
011901120816     p TRACEDATA_clearCache...
011902120816     p                 b                   export
011903120816     d                 pi
011904120816
011905120816      /free
011906120816       clear cacheSize;
011907120816       clear recordCache;
011908120816       return ;
011909120816      /end-free
011910120816     p                 e
011911120816      //_______________________________________________________________________
011912120816
012000120816     p TRACEDATA_write...
012100120816     p                 b                   export
012400120816     d                 pi              n
012703120816      /free
012800121001       EXEC SQL
012900121001        INSERT INTO TRACEDATA(TRACEID, REGTIME, CODSTMT, CODESEQ, CODEDTA,
013500121001                              CODEDATE, PGMLIB, PGMNAME, PGMTYPE, MDLNAME,
013900121001                              PROCNAME, JOBNAME, JOBNUM,  JOBUSER, CASEID)
014300121001             VALUES(:TRACEDATARECORD);
014500120816
014501120816       return CSQLUTIL_checksqlstate(sqlstt:'TRACEDATA WRITE');
015100120816      /end-free
015400120816     p                 e
015500120816      //_______________________________________________________________________
015600120816
015601120816     p TRACEDATA_writeWithCaching...
015602120816     p                 b                   export
015603120816     d                 pi              n
015604120816     d writeImmediately...
015605120816     d                                 n   const
015606120816
015607120816      /free
015608120816       if writeImmediately;
015609120816         TRACEDATA_flushRecordCache();
015610120816         return TRACEDATA_write;
015618120816       else;
015619120816         if (cacheSize = CACHE_MAX_SIZE);
015620120816           TRACEDATA_flushRecordCache();
015622120816         endif;
015623120816
015624120816         cacheSize += 1;
015625120816         recordCache(cacheSize) = traceDataRecord;
015626120816         return *on;
015627120816       endif;
015628120816      /end-free
015629120816     p                 e
015630120816      //_______________________________________________________________________
015631120816
015800120816     p TRACEDATA_delete...
015900120816     p                 b                   export
016200120816     d                 pi              n
016500120816
016501120816      /free
016600121001       EXEC SQL
016700121001         DELETE
016800121001           FROM TRACEDATA
016900121001          WHERE TRACEID = :TRACEDATARECORD.TRACEID;
017000120816
017500120816       TRACEDATA_clear();
017501120816
017600120816       return CSQLUTIL_checkSQLState(sqlstt:'TRACEDATA DELETE');
017700120816      /end-free
018000120816     p                 e
021200120816      //_______________________________________________________________________
021201120816
021202120816     p TRACEDATA_deleteAll...
021203120816     p                 b                   export
021204120816     d                 pi              n
021205120816
021206120816      /free
021207121001       EXEC SQL
021208121001         DELETE
021209121001           FROM TRACEDATA;
021211120816
021212120816       TRACEDATA_clear();
021213120816
021214120816       return CSQLUTIL_checkSQLState(sqlstt:'TRACEDATA DELETE ALL');
021215120816      /end-free
021216120816     p                 e
021217120816      //_______________________________________________________________________
021220120816
021221120816     p TRACEDATA_flushRecordCache...
021222120816     p                 b                   export
021223120816     d                 pi              n
021224120816
021225120816      /free
021226120817       if cacheSize > 0;
021228121001         EXEC SQL
021229121001           INSERT INTO TRACEDATA(TRACEID, REGTIME, CODSTMT, CODESEQ, CODEDTA,
021230121001                                 CODEDATE, PGMLIB, PGMNAME, PGMTYPE, MDLNAME,
021231121001                                 PROCNAME, JOBNAME, JOBNUM,  JOBUSER, CASEID)
021232121001                  :CACHESIZE ROWS VALUES (:RECORDCACHE);
021233120816
021234120817         clear cacheSize;
021235120817         clear recordCache;
021236120817         return CSQLUTIL_checkSQLState(sqlstt:'FLUSH CACHE');
021237120817       else;
021238120817         return *ON;
021239120817       endif;
021240120816      /end-free
021241120816     p                 e
021242120816      //_______________________________________________________________________
021243120816
021244120816     p TRACEDATA_getNextTraceId...
021245120816     p                 b                   export
021246120816     d                 pi            10i 0
021247120816     d traceId         s             10i 0
021248120816
021249120816      /free
021250121001       EXEC SQL
021251121001         SELECT TRACEID
021252121001           INTO :TRACEID
021253121001           FROM TRACEDATA
021254121001          ORDER BY TRACEID DESC
021255121001          FETCH FIRST 1 ROW ONLY;
021256120816
021257120816       CSQLUTIL_checkSQLState(SQLSTATE:'SELECT TRACEID');
021258120816
021259120816       traceId += 1;
021260120816       return traceId;
021262120816      /end-free
021263120816     p                 e
021264120816
021300120816      /////////////////////////////////////////////////////////////////
021400120816      // Getters
021500120816      /////////////////////////////////////////////////////////////////
021600120816
021700120816     p TRACEDATA_getTRACEID...
021800120816     p                 b                    export
022100120816     d                 pi            10i 0
022300120816      /free
022400120816        return traceDataRecord.TRACEID ;
022500120816      /end-free
022800120816     p                 e
023000120816      //_____________________________________________________________________
023100120816
023200120816     p TRACEDATA_getREGTIME...
023300120816     p                 b                    export
023600120816     d                 pi              z
023700120816
023800120816      /free
023900120816        return traceDataRecord.REGTIME ;
024000120816      /end-free
024300120816     p                 e
024500120816      //_____________________________________________________________________
024600120816
024700120816     p TRACEDATA_getCODESEQ...
024800120816     p                 b                    export
025100120816     d                 pi             6a
025200120816
025300120816      /free
025400120816        return traceDataRecord.CODESEQ ;
025500120816      /end-free
025800120816     p                 e
026000120816      //_____________________________________________________________________
026100120816
026101120821     p TRACEDATA_getSTMTNUMBER...
026102120821     p                 b                   export
026103120821     d                 pi            10i 0
026104120821
026105120821      /free
026106120821       return traceDataRecord.CODSTMT;
026107120821      /end-free
026108120821     p                 e
026109120821      //_____________________________________________________________________
026110120821
026200120816     p TRACEDATA_getCODEDTA...
026300120816     p                 b                    export
026600120816     d                 pi           255a
026700120816
026800120816      /free
026900120816        return traceDataRecord.CODEDTA ;
027000120816      /end-free
027300120816     p                 e
027500120816      //_____________________________________________________________________
027600120816
027601121001     p TRACEDATA_getCODEDATE...
027602121001     p                 b                   export
027603121001     d                 pi              d
027604121001
027605121001      /free
027606121001       return traceDataRecord.CODEDATE;
027607121001      /end-free
027608121001     p                 e
027609121001      //_____________________________________________________________________
027610121001
027700120816     p TRACEDATA_getPGMLIB...
027800120816     p                 b                    export
028100120816     d                 pi            10a
028101120816
028300120816      /free
028400120816        return traceDataRecord.PGMLIB ;
028500120816      /end-free
028800120816     p                 e
029000120816      //_____________________________________________________________________
029100120816
029200120816     p TRACEDATA_getPGMNAME...
029300120816     p                 b                    export
029600120816     d                 pi            10a
029700120816
029800120816      /free
029900120816        return traceDataRecord.PGMNAME ;
030000120816      /end-free
030300120816     p                 e
030500120816      //_____________________________________________________________________
030600120816
030601121001     p TRACEDATA_getPGMTYPE...
030602121001     p                 b                    export
030603121001     d                 pi            10a
030605121001
030606121001      /free
030607121001        return traceDataRecord.PGMTYPE;
030609121001      /end-free
030610121001     p                 e
030611121001      //____________________________________________________________________
030612121001
030700120816     p TRACEDATA_getMDLNAME...
030800120816     p                 b                    export
031100120816     d                 pi            10a
031200120816
031300120816      /free
031400120816        return traceDataRecord.MDLNAME ;
031500120816      /end-free
031800120816     p                 e
032000120816      //_____________________________________________________________________
032100120816
032200120816     p TRACEDATA_getPROCNAME...
032300120816     p                 b                    export
032600120816     d                 pi          1024a   varying
032800120816      /free
032900120816        return traceDataRecord.PROCNAME ;
033000120816      /end-free
033300120816     p                 e
033400120816
033500120816      //_____________________________________________________________________
033600120816
033700120816     p TRACEDATA_getJOBNAME...
033800120816     p                 b                    export
034100120816     d                 pi            10a
034200120816
034300120816      /free
034400120816        return traceDataRecord.JOBNAME ;
034500120816      /end-free
034800120816     p                 e
035000120816      //_____________________________________________________________________
035100120816
035200120816     p TRACEDATA_getJOBNUM...
035300120816     p                 b                    export
035600120816     d                 pi             6a
035700120816
035800120816      /free
035900120816        return traceDataRecord.JOBNUM ;
036000120816      /end-free
036300120816     p                 e
036500120816      //_____________________________________________________________________
036600120816
036700120816     p TRACEDATA_getJOBUSER...
036800120816     p                 b                    export
037100120816     d                 pi            10a
037200120816
037300120816      /free
037400120816        return traceDataRecord.JOBUSER ;
037500120816      /end-free
037800120816     p                 e
038000120816      //_____________________________________________________________________
038100120816
038200120816     p TRACEDATA_getCASEID...
038300120816     p                 b                    export
038600121001     d                 pi            20a
038700120816
038800120816      /free
038900120816        return traceDataRecord.CASEID ;
039000120816      /end-free
039300120816     p                 e
039400120816
039500120816      /////////////////////////////////////////////////////////////////
039501120816      // Setters
039502120816      /////////////////////////////////////////////////////////////////
039800120816
039900120816     p TRACEDATA_setTRACEID...
040000120816     p                 b                    export
040300120816     d                 pi
040400120816     d TRACEID                       10i 0 const
040500120816
040600120816      /free
040700120816        traceDataRecord.TRACEID = TRACEID ;
040800120816        return ;
040900120816      /end-free
041200120816     p                 e
041400120816      //_____________________________________________________________________
041500120816
041600120816     p TRACEDATA_setREGTIME...
041700120816     p                 b                    export
042000120816     d                 pi
042100120816     d REGTIME                         z   const
042200120816
042300120816      /free
042400120816        traceDataRecord.REGTIME = REGTIME ;
042500120816        return ;
042600120816      /end-free
042900120816     p                 e
043100120816      //_____________________________________________________________________
043200120816
043300120816     p TRACEDATA_setCODESEQ...
043400120816     p                 b                    export
043700120816     d                 pi
043800120816     d CODESEQ                        6a   const
043900120816
044000120816      /free
044100120816        traceDataRecord.CODESEQ = CODESEQ ;
044200120816        return ;
044300120816      /end-free
044600120816     p                 e
044800120816      //_____________________________________________________________________
044900120816
044901120821     p TRACEDATA_setSTMTNUMBER...
044902120821     p                 b                   export
044903120821     d                 pi
044904120821     d STMTNUMBER                    10i 0 const
044905120821
044906120821      /free
044907120821        traceDataRecord.CODSTMT = STMTNUMBER;
044908120821        return;
044909120821      /end-free
044910120821     p                 e
044911120821      //_____________________________________________________________________
044912120821
045000120816     p TRACEDATA_setCODEDTA...
045100120816     p                 b                    export
045400120816     d                 pi
045500120816     d CODEDTA                      255a   const
045600120816
045700120816      /free
045800120816        traceDataRecord.CODEDTA = CODEDTA ;
045900120816        return ;
046000120816      /end-free
046300120816     p                 e
046500120816      //_____________________________________________________________________
046600120816
046601121001     p TRACEDATA_setCODEDATE...
046602121001     p                 b                   export
046603121001     d                 pi
046604121001     d CODEDATE                        d   const
046605121001
046606121001      /free
046607121001       traceDataRecord.CODEDATE = CODEDATE;
046608121001      /end-free
046609121001     p                 e
046610121001      //_____________________________________________________________________
046611121001
046700120816     p TRACEDATA_setPGMLIB...
046800120816     p                 b                    export
047100120816     d                 pi
047200120816     d PGMLIB                        10a   const
047300120816
047400120816      /free
047500120816        traceDataRecord.PGMLIB = PGMLIB ;
047600120816        return ;
047700120816      /end-free
048000120816     p                 e
048200120816      //_____________________________________________________________________
048300120816
048400120816     p TRACEDATA_setPGMNAME...
048500120816     p                 b                    export
048800120816     d                 pi
048900120816     d PGMNAME                       10a   const
049000120816
049100120816      /free
049200120816        traceDataRecord.PGMNAME = PGMNAME ;
049300120816        return ;
049400120816      /end-free
049700120816     p                 e
049900120816      //_____________________________________________________________________
050000121001
050001121001     p TRACEDATA_setPGMTYPE...
050002121001     p                 b                    export
050003121001     d                 pi
050004121001     d PGMTYPE                       10a   const
050005121001
050006121001      /free
050007121001        traceDataRecord.PGMTYPE = PGMTYPE;
050008121001        return ;
050009121001      /end-free
050010121001     p                 e
050011121001      //____________________________________________________________________
050012121001
050100120816     p TRACEDATA_setMDLNAME...
050200120816     p                 b                    export
050500120816     d                 pi
050600120816     d MDLNAME                       10a   const
050700120816
050800120816      /free
050900120816        traceDataRecord.MDLNAME = MDLNAME ;
051000120816        return ;
051100120816      /end-free
051400120816     p                 e
051600120816      //_____________________________________________________________________
051700120816
051800120816     p TRACEDATA_setPROCNAME...
051900120816     p                 b                    export
052200120816     d                 pi
052300120816     d PROCNAME                    1024a   const varying
052400120816
052500120816      /free
052600120816        traceDataRecord.PROCNAME = PROCNAME ;
052700120816        return ;
052800120816      /end-free
053100120816     p                 e
053300120816      //_____________________________________________________________________
053400120816
053500120816     p TRACEDATA_setJOBNAME...
053600120816     p                 b                    export
053900120816     d                 pi
054000120816     d JOBNAME                       10a   const
054100120816
054200120816      /free
054300120816        traceDataRecord.JOBNAME = JOBNAME ;
054400120816        return ;
054500120816      /end-free
054800120816     p                 e
054900120816
055000120816      //_____________________________________________________________________
055100120816
055200120816     p TRACEDATA_setJOBNUM...
055300120816     p                 b                    export
055600120816     d                 pi
055700120816     d JOBNUM                         6a   const
055800120816
055900120816      /free
056000120816        traceDataRecord.JOBNUM = JOBNUM ;
056100120816        return ;
056200120816      /end-free
056500120816     p                 e
056700120816      //_____________________________________________________________________
056800120816
056900120816     p TRACEDATA_setJOBUSER...
057000120816     p                 b                    export
057300120816     d                 pi
057400120816     d JOBUSER                       10a   const
057500120816
057600120816      /free
057700120816        traceDataRecord.JOBUSER = JOBUSER ;
057800120816        return ;
057900120816      /end-free
058200120816     p                 e
058400120816      //_____________________________________________________________________
058500120816
058600120816     p TRACEDATA_setCASEID...
058700120816     p                 b                    export
059000120816     d                 pi
059100121001     d caseId                        20a   const
059200120816
059300120816      /free
059400121017       traceDataRecord.CASEID = caseId;
059500120816       return;
059600120816      /end-free
059900120816     p                 e
060000120816
